package com.baizhi.service.ServiceImpl;

import com.baizhi.dao.RoleDao;
import com.baizhi.entity.Banner;
import com.baizhi.entity.Role;
import com.baizhi.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/4/21.
 */

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;

    @Override
    public Map selectAllRole(int rows,int page,String Rolename) {


        Map map=new HashMap();
        if(Rolename!=null){
            if("".equals(Rolename)){
                Rolename=null;
            }else{
                Rolename="%"+Rolename+"%";
            }
        }
        int begin=rows*(page-1);
        int size=rows;
        Integer count=roleDao.selectAllRoleCount();
        List<Role> roleList=roleDao.selectAllRole(begin,size,Rolename);

        map.put("total",count);
        map.put("rows",roleList);

        return map;

    }
}
